package org.afk.sisy;

import java.util.*;

import org.afk.sisy.io.*;

public class PathWrapperMatcher
{

	private final Map<String, PathWrapper> files = new HashMap<String, PathWrapper>();

	public synchronized PathWrapper match(final PathWrapper next)
	{
		final String key = next.getRelativePath().toString();
		if (files.containsKey(key))
			return files.remove(key);
		files.put(key, next);
		return null;
	}

	public List<PathWrapper> removeUnmatched()
	{
		final List<PathWrapper> values = new ArrayList<PathWrapper>(files.values());
		files.clear();
		return values;
	}

}
